<?php
include_once 'dbcofig.php';
// 用户名访问系统时，首先根据session判定用户是否登录
    session_start ();
	$a=$_SESSION ['username'];
	if(isset($_GET['id'])){
		$_SESSION['ID']=$_GET['id'];
	}
	if(isset($_SESSION['ID'])){
		$id=$_SESSION['ID'];
		$statement="select year,teacerId,textname,menny,status from noteachhour where id=?";
		$statementdb=$pdo->prepare($statement);
		$data=array($id);
		$statementdb->execute($data);
		$DATA=$statementdb->fetch();
	}else{
		echo "<h1>:(</h1>莫得数据哦！<a href='form.php' class='btn btn-primary'>返回</a>";
		exit();
	}
	if(isset($_REQUEST['teacerId'])){
		$year=$_REQUEST['year'];
		$teacerId=$_REQUEST['teacerId'];
		$textname=$_REQUEST['textname'];
		$status=$_REQUEST['status'];
		$menny=$_REQUEST['menny'];
		$id=$_SESSION['ID'];
		$statement="update noteachhour set year=?,teacerId=?,textname=?,menny=?,status=? where id=?";
		$statementdb=$pdo->prepare($statement);
		$data=array($year,$teacerId,$textname,$menny,$status,$id);
		$statementdb->execute($data);
		if($statementdb->rowCount()>0){
			echo "<h1>:)</h1>修改成功！<a href='form.php' class='btn btn-primary'>返回</a>";
			exit();
		}else{
			echo "<h1>:(</h1>修改失败！<a href='form.php' class='btn btn-primary'>返回</a>";
			exit();
		}
	}
	
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
      <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>教师端非授课量页面编辑</title>
	<!-- BOOTSTRAP STYLES-->
    <link href="../assets/css/bootstrap.css" rel="stylesheet" />
     <!-- FONTAWESOME STYLES-->
    <link href="../assets/css/font-awesome.css" rel="stylesheet" />
     <!-- MORRIS CHART STYLES-->
   
        <!-- CUSTOM STYLES-->
    <link href="../assets/css/custom.css" rel="stylesheet" />
     <!-- GOOGLE FONTS-->
   	<link href="../assets/css/opensans.css" rel='stylesheet' type='text/css' />
     <!-- TABLE STYLES-->
    <link href="../assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
</head>
<body>
    <div id="wrapper">
        <nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="intex.php"><?php echo $a."的信息"?></a> 
            </div>
  <div style="color: white;
padding: 15px 50px 5px 50px;
float: right;	
font-size: 16px;"> 用户名: <?php echo $a;?> &nbsp; <a href="login.php" class="btn btn-danger square-btn-adjust">注销</a> </div>
        </nav>   
           <!-- /. NAV TOP  -->
                <nav class="navbar-default navbar-side" role="navigation">
            <div class="sidebar-collapse">
                <ul class="nav" id="main-menu">
				<li class="text-center">
                    <img src="../assets/img/find_user.png" class="user-image img-responsive"/>
					</li>
				
					
                    
                      <li  >
                        <a   href="table.php"><i class="fa fa-table fa-3x"></i> 授课量统计</a>
                    </li>
                    <li  >
                        <a class="active-menu"  href="form.php"><i class="fa fa-edit fa-3x"></i> 非授课量统计 </a>
                    </li>				
                </ul>
               
            </div>
            
        </nav>  
        <!-- /. NAV SIDE  -->
        <div id="page-wrapper" >
            <div id="page-inner">
                <div class="row">
                    <div class="col-md-12">
                     <h2>编辑修改页面</h2>   
                        <h5>请在对应框填写你要修改的数据！</h5>
                       
                    </div>	
                </div>
                 <!-- /. ROW  -->
                  <div class="row">
                <div class="col-md-12">
                <div class="panel panel-default">
                        <div class="panel-heading">
                             表格
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                            <form action='noupdatescore.php' method='post'>
	<table align='center'>
	
		<tr>
			<td>年度：</td>
			<td><select class="form-control" name="year">
<option value="2017" <?= $DATA['year']=='2017'?'selected':'' ?>>2017年</option>
<option value="2018" <?= $DATA['year']=='2018'?'selected':'' ?>>2018年</option>
<option value="2019" <?= $DATA['year']=='2019'?'selected':'' ?>>2019年</option>
<option value="2020" <?= $DATA['year']=='2020'?'selected':'' ?>>2020年</option>
<option value="2021" <?= $DATA['year']=='2021'?'selected':'' ?>>2021年</option>
</select></td>
		</tr>
		<tr>
			<td>教工号：</td>
			<td><input type='text' name='teacerId' value='<?=$DATA['teacerId']?>'></td>
		</tr>
		<tr>
			<td>教学工作量：</td>
			<td><input type='text' name='textname' value='<?=$DATA['textname']?>'></td>
		</tr>
		<tr>
			<td>记录人：</td>
			<td><input type='text' name='menny' value='<?=$DATA['menny']?>'></td>
		</tr>
		
		<tr>
			<td>状态：</td>
			<td>
			<select class="form-control" name="status">
			<option value="确认" <?= $DATA['status']=='确认'?'selected':'' ?>>确认</option>
            <option value="待审" <?= $DATA['status']=='待审'?'selected':'' ?>>待审</option>
			</select>
			</td>
		</tr>
		<tr>
			<td><input type='submit' name='ddd'
				value='保存数据' /></td>
			<td><input type='reset' value="重置"/></td>
			
		    <td><a class="btn btn-primary" href="form.php">取消返回</a></td> 
		</tr>

	</table>
</form>
                </div></div></div>
                
                </div></div>
               
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    	
                        
                    <!--End Advanced Tables -->
                </div>
            </div>
             		
        </div>
               
    </div>
             <!-- /. PAGE INNER  -->
            </div>
         <!-- /. PAGE WRAPPER  -->
     <!-- /. WRAPPER  -->
    <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
    <!-- JQUERY SCRIPTS -->
    <script src="../assets/js/jquery-1.10.2.js"></script>
      <!-- BOOTSTRAP SCRIPTS -->
    <script src="../assets/js/bootstrap.min.js"></script>
    <!-- METISMENU SCRIPTS -->
    <script src="../assets/js/jquery.metisMenu.js"></script>
     <!-- DATATABLES SCRIPTS -->
    <script src="../assets/js/dataTables/jquery.dataTables.js"></script>
    <!-- bootstrap SCRIRTS-->
    <script src="../assets/js/dataTables/dataTables.bootstrap.js"></script>
        <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });
    </script>
         <!-- CUSTOM SCRIPTS -->
    <script src="../assets/js/custom.js"></script>
    
   
</body>
</html>
